/*---------------------------------------------------------------------------------------------
 *  Copyright (c) kylinIDETeam. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import { localize } from 'vs/nls';
import { ConfigurationScope, Extensions as ConfigurationExtensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';

const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
	id: 'extensionsGallery',
	order: 199,
	title: localize('extensionsGalleryConfigurationTitle', "extensionsGallery"),
	type: 'object',
	properties: {
		'extensionsGallery.serviceUrl': {
			type: 'string',
			pattern: '^(http|https)?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$',
			default: '',
			scope: ConfigurationScope.APPLICATION,
			description: localize('extensionsGalleryServiceUrl', "Configure Extensions Gallery ServiceUrl.Sample:https://open-vsx.org/vscode/gallery"),
			restricted: true
		},
		'extensionsGallery.itemUrl': {
			type: 'string',
			pattern: '^(http|https)?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$',
			default: '',
			scope: ConfigurationScope.APPLICATION,
			description: localize('extensionsGalleryItemUrl', "Configure Extensions Gallery ItemUrl.Sample:https://open-vsx.org/vscode/item"),
			restricted: true,

		},
		'extensionsGallery.trustDomains': {
			type: 'array',
			items: {
				type: 'string'
			},
			default: [],
			description: localize('extensionsGalleryTrustDomains', "Configure Trusted Domains,Sample:https://open-vsx.org"),
			scope: ConfigurationScope.RESOURCE
		}
	},
});

export interface IExtensionsGalleryConfiguration {
	// extensionsGallery?: {
	serviceUrl: string;
	itemUrl: string;
	trustDomains: string[];
	// }

}
